.TH std::locale::id 3 "2024.06.10" "http://cppreference.com" "C++ Standard Libary"
.SH NAME
std::locale::id \- std::locale::id

.SH Synopsis
   Defined in header <locale>
   class locale::id;

   The class std::locale::id provides implementation-specific identification of a
   locale facet. Each facet has a public static member named id of type std::locale::id
   and each std::locale object maintains a list of facets it implements, indexed by
   their ids.

   Facets with the same id belong to the same facet category and replace each other
   when added to a locale object.

.SH Member functions

   constructor   constructs a new id
                 \fI(public member function)\fP
   operator=     copy assignment operator is deleted
                 \fI(public member function)\fP

.SH Example

   The following example shows how to construct a minimal custom facet.


// Run this code

 #include <iostream>
 #include <locale>

 struct myfacet : std::locale::facet
 {
     myfacet(std::size_t refs = 0) : facet(refs) {}
     static ::std::locale::id id;
 };

 std::locale::id myfacet::id;

 int main()
 {
     std::locale myloc(std::locale(), new myfacet);
     std::cout << "has_facet<myfacet>(myloc) returns " << std::boolalpha
               << std::has_facet<myfacet>(myloc) << '\\n';
 }

.SH Output:

 has_facet<myfacet>(myloc) returns true

.SH See also

         the base class for all facet categories: each facet of any category is derived
   facet from this type
         \fI(class)\fP
